<?php
include_once('../bootstrap.php');
Doctrine_Query::create()->update('Email')->set('estado', '1')->where('estado = 0')->execute();
$emails = Doctrine_Query::create()->select('value, nombre')->from('Email e')->where('value IS NOT NULL')->execute(array(), Doctrine::HYDRATE_ARRAY);
$csv = "Emails; Nombres\n";
for ($i=0, $l=count($emails); $i<$l; $i++) {
    $csv .= $emails[$i]['value']."; ".$emails[$i]['nombre']."\n";
}
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="emails_'.date('d-m-Y').'.csv"');
echo($csv);
?>